package com.feonix.complat.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.feonix.common.basedao.BaseJdbcDAO;
import com.feonix.common.basedao.Query;
import com.feonix.complat.constant.Tables;
import com.feonix.complat.entity.RoleRight;

/**
 * 角色权限关系
 * 
 * @author feonix
 * 
 */
@Repository
public class RoleRightDAO extends BaseJdbcDAO<Integer, RoleRight> {

	/**
	 * 通过角色ID串删除角色权限对应关系
	 * 
	 * @param roleIds
	 *            角色ID串 如:1,2,3
	 * @return true - 成功<br/>
	 *         false - 失败
	 */
	public boolean deleteByRoleIds(List<Integer> roleIds) {
		String sql = "DELETE FROM " + Tables.ROLERIGHT + " WHERE roleid IN (:roleIds)";
		Query query = createQuery(sql);
		query.addParameter("roleIds", roleIds);

		return this.delete(query);
	}

	/**
	 * 通过功能权限删除对应的角色权限对应关系
	 * @param idsList
	 * @return
	 */
	public boolean deleteByRightIds(List<Integer> rightIdsList) {
		String sql = "DELETE FROM " + Tables.ROLERIGHT + " WHERE rightid IN (:rightIds)";
		Query query = createQuery(sql);
		query.addParameter("rightIds", rightIdsList);
		return this.delete(query);
	}

}
